package com.macro.ai.function.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Description;

import java.util.function.Function;

/**
 * @ClassName CalculatorService
 * @Description function配置类
 * @Author wanghong
 * @Date 2025/6/21 11:13
 * @Version 1.0
 **/
@Configuration
public class CalculatorService {
    public record AddOperation(Double a, Double b) {

    }

    public record MulOperation(Double m, Double n) {

    }

    //注册
    //Function<抽象方法,结果类型>
    @Bean
    @Description("加法运算")
    public Function<AddOperation, Double> addOperation() {
        System.out.println("调用加法");
        return request -> {
            return request.a+request.b;
        };
    }

    @Bean
    @Description("乘法运算")
    public Function<MulOperation, Double> mulOperation() {
        System.out.println("调用乘法");
        return request -> {
            return request.m*request.n;
        };
    }


}
